package com.esri.core.portal;

import androidx.core.app.NotificationCompat;
import com.esri.core.internal.tasks.ags.PortalFetchThumbnail;
import com.esri.core.internal.tasks.ags.ag;
import com.esri.core.internal.tasks.ags.ah;
import com.esri.core.internal.tasks.ags.al;
import com.esri.core.internal.util.d;
import com.esri.core.internal.util.g;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class PortalUser {
    final Portal a;
    String b;
    String c;
    String d;
    String e;
    List<String> f;
    long g;
    long h;
    List<PortalGroup> i;
    PortalAccess j;
    String k;
    PortalUserRole l = null;

    PortalUser(Portal portal) {
        this.a = portal;
    }

    public static PortalUser newInstance(Portal portal, String str) throws Exception {
        return new ag(new al(portal), portal.findSharingUrl(), portal.b).execute();
    }

    public PortalUserContent fetchContent() throws Exception {
        return fetchContentInFolder(null);
    }

    public PortalUserContent fetchContentInFolder(String str) throws Exception {
        String str2 = this.b;
        if (str2 == null || "".equals(str2)) {
            return null;
        }
        return new ah(new al(this.a), this.a.findSharingUrl(), this.b, str, this.a.b).execute();
    }

    private final String a() {
        try {
            return this.a.findSharingUrl() + "/community/users/" + this.b + "/info/" + this.d;
        } catch (Exception unused) {
            return null;
        }
    }

    public byte[] fetchThumbnail() throws Exception {
        String str = this.d;
        if (str == null || str.trim().length() == 0 || "null".equalsIgnoreCase(this.d)) {
            return null;
        }
        return new PortalFetchThumbnail(a(), this.a.b).execute();
    }

    public static PortalUser fromJson(JsonParser jsonParser, Portal portal) throws Exception {
        if (d.c(jsonParser)) {
            PortalUser portalUser = new PortalUser(portal);
            jsonParser.enable(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS);
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if (currentName.equals("created")) {
                    portalUser.g = jsonParser.getLongValue();
                } else if (currentName.equals(NotificationCompat.CATEGORY_EMAIL)) {
                    portalUser.e = jsonParser.getText();
                } else if (currentName.equals("fullName")) {
                    portalUser.c = jsonParser.getText();
                } else if (currentName.equals("groups")) {
                    portalUser.i = new ArrayList();
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        portalUser.i.add(PortalGroup.fromJson(jsonParser, portal));
                    }
                } else if (currentName.equals("modified")) {
                    portalUser.h = jsonParser.getLongValue();
                } else if (currentName.equals("tags")) {
                    portalUser.f = new ArrayList();
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        portalUser.f.add(jsonParser.getText());
                    }
                } else if (currentName.equals("thumbnail")) {
                    portalUser.d = jsonParser.getText();
                } else if (currentName.equals("username")) {
                    portalUser.b = jsonParser.getText();
                } else if (currentName.equals("access")) {
                    portalUser.j = PortalAccess.a(jsonParser.getText(), portal.isPreVersion162());
                } else if (currentName.equals("role")) {
                    String text = jsonParser.getText();
                    if (g.b(text)) {
                        portalUser.l = PortalUserRole.fromString(text.toLowerCase());
                    }
                } else if (currentName.equals("orgId")) {
                    portalUser.k = jsonParser.getText();
                } else if (currentName.equals("accountid")) {
                    portalUser.k = jsonParser.getText();
                } else {
                    jsonParser.skipChildren();
                }
            }
            return portalUser;
        }
        return null;
    }

    public Portal getPortal() {
        return this.a;
    }

    public String getUsername() {
        return this.b;
    }

    public String getFullName() {
        return this.c;
    }

    public String getThumbnailFileName() {
        return this.d;
    }

    public String getEmail() {
        return this.e;
    }

    public List<String> getTags() {
        return this.f;
    }

    public long getCreated() {
        return this.g;
    }

    public long getModified() {
        return this.h;
    }

    public List<PortalGroup> getGroups() {
        return this.i;
    }

    public PortalAccess getAccess() {
        return this.j;
    }

    public PortalUserRole getRole() {
        return this.l;
    }

    public String getOrganizationId() {
        return this.k;
    }

    public int hashCode() {
        PortalAccess portalAccess = this.j;
        int hashCode = portalAccess == null ? 0 : portalAccess.hashCode();
        long j = this.g;
        int i = (((hashCode + 31) * 31) + ((int) (j ^ (j >>> 32)))) * 31;
        String str = this.e;
        int hashCode2 = (i + (str == null ? 0 : str.hashCode())) * 31;
        String str2 = this.c;
        int hashCode3 = (hashCode2 + (str2 == null ? 0 : str2.hashCode())) * 31;
        List<PortalGroup> list = this.i;
        int hashCode4 = list == null ? 0 : list.hashCode();
        long j2 = this.h;
        int i2 = (((hashCode3 + hashCode4) * 31) + ((int) (j2 ^ (j2 >>> 32)))) * 31;
        String str3 = this.k;
        int hashCode5 = (i2 + (str3 == null ? 0 : str3.hashCode())) * 31;
        Portal portal = this.a;
        int hashCode6 = (hashCode5 + (portal == null ? 0 : portal.getUrl().hashCode())) * 31;
        PortalUserRole portalUserRole = this.l;
        int hashCode7 = (hashCode6 + (portalUserRole == null ? 0 : portalUserRole.hashCode())) * 31;
        List<String> list2 = this.f;
        int hashCode8 = (hashCode7 + (list2 == null ? 0 : list2.hashCode())) * 31;
        String str4 = this.d;
        int hashCode9 = (hashCode8 + (str4 == null ? 0 : str4.hashCode())) * 31;
        String str5 = this.b;
        return hashCode9 + (str5 != null ? str5.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            PortalUser portalUser = (PortalUser) obj;
            if (this.j == portalUser.j && this.g == portalUser.g) {
                String str = this.e;
                if (str == null) {
                    if (portalUser.e != null) {
                        return false;
                    }
                } else if (!str.equals(portalUser.e)) {
                    return false;
                }
                String str2 = this.c;
                if (str2 == null) {
                    if (portalUser.c != null) {
                        return false;
                    }
                } else if (!str2.equals(portalUser.c)) {
                    return false;
                }
                List<PortalGroup> list = this.i;
                if (list == null) {
                    if (portalUser.i != null) {
                        return false;
                    }
                } else if (!list.equals(portalUser.i)) {
                    return false;
                }
                if (this.h != portalUser.h) {
                    return false;
                }
                String str3 = this.k;
                if (str3 == null) {
                    if (portalUser.k != null) {
                        return false;
                    }
                } else if (!str3.equals(portalUser.k)) {
                    return false;
                }
                Portal portal = this.a;
                if (portal == null) {
                    if (portalUser.a != null) {
                        return false;
                    }
                } else if (!portal.getUrl().equals(portalUser.a.getUrl())) {
                    return false;
                }
                if (this.l != portalUser.l) {
                    return false;
                }
                List<String> list2 = this.f;
                if (list2 == null) {
                    if (portalUser.f != null) {
                        return false;
                    }
                } else if (!list2.equals(portalUser.f)) {
                    return false;
                }
                String str4 = this.d;
                if (str4 == null) {
                    if (portalUser.d != null) {
                        return false;
                    }
                } else if (!str4.equals(portalUser.d)) {
                    return false;
                }
                String str5 = this.b;
                if (str5 == null) {
                    if (portalUser.b != null) {
                        return false;
                    }
                } else if (!str5.equals(portalUser.b)) {
                    return false;
                }
                return true;
            }
            return false;
        }
        return false;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("PortalUser [");
        if (this.a != null) {
            sb.append("portal=");
            sb.append(this.a.getUrl());
            sb.append(", ");
        }
        if (this.b != null) {
            sb.append("username=");
            sb.append(this.b);
            sb.append(", ");
        }
        if (this.c != null) {
            sb.append("fullName=");
            sb.append(this.c);
            sb.append(", ");
        }
        if (this.d != null) {
            sb.append("thumbnailFileName=");
            sb.append(this.d);
            sb.append(", ");
        }
        if (this.e != null) {
            sb.append("email=");
            sb.append(this.e);
            sb.append(", ");
        }
        if (this.f != null) {
            sb.append("tags=");
            sb.append(this.f);
            sb.append(", ");
        }
        sb.append("created=");
        sb.append(this.g);
        sb.append(", modified=");
        sb.append(this.h);
        sb.append(", ");
        if (this.i != null) {
            sb.append("groups=");
            sb.append(this.i);
            sb.append(", ");
        }
        if (this.j != null) {
            sb.append("access=");
            sb.append(this.j);
            sb.append(", ");
        }
        if (this.k != null) {
            sb.append("organizationId=");
            sb.append(this.k);
            sb.append(", ");
        }
        if (this.l != null) {
            sb.append("role=");
            sb.append(this.l);
        }
        sb.append("]");
        return sb.toString();
    }
}
